﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="Secondhand_Book_Trade.Register" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>注册</title>
    <!-- jQuery -->
    <script src="Scripts/jquery-3.7.1.js"></script>
    <style type="text/css">
            html{
                background-color: #BAF6FD;
            }
            table {
                border: 1px solid #666;        /* 边框粗细和颜色 */
                border-collapse: collapse;     /* 合并边框 */
                background-color: #fff;         /* 表格背景色 */
                margin: 20px auto;             /* 居中显示 */
            }
             .td_1{
               text-align:right;
               top:0;
           }
           .td1{
               text-align:right;
           }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div class="div">
            <!-- 数据源控件 -->
            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                ConnectionString="<%$ ConnectionStrings:Secondhand_book_tradeConnectionString %>"
                InsertCommand="INSERT INTO Users (Username, Password, Email, Phone, Role, Gender, Nickname) VALUES (@Username, @Password, @Email, @Phone, @Role, @Gender, @Nickname)">
                <InsertParameters>
                    <asp:ControlParameter Name="Username" ControlID="txtname" PropertyName="Text" />
                    <asp:ControlParameter Name="Password" ControlID="txtpassword" PropertyName="Text" />
                    <asp:ControlParameter Name="Email" ControlID="email" PropertyName="Text" />
                    <asp:ControlParameter Name="Phone" ControlID="txtPhoneNumber" PropertyName="Text" />
                    <asp:ControlParameter Name="Role" ControlID="ddlRole" PropertyName="SelectedValue" />
                    <asp:ControlParameter Name="Gender" ControlID="DropDownList1" PropertyName="SelectedValue" />
                    <asp:ControlParameter Name="Nickname" ControlID="txtname1" PropertyName="Text" />
                </InsertParameters>
            </asp:SqlDataSource>
            <table>
                <tr>
                    <td colspan="3" align="center" style="font-size:16pt; height:40px; vertical-align:bottom;color:maroon;font-weight:bold;width:750px;">注册页面</td>
                </tr>
                <tr>
                    <td class="td_1">用户名:</td>
                    <td class="td2">
                        <asp:TextBox ID="txtname" runat="server" Columns="40"></asp:TextBox>
                        &nbsp;
                        <asp:RequiredFieldValidator ID="reqname" runat="server" ErrorMessage="必填" ControlToValidate="txtname" ForeColor="Red"></asp:RequiredFieldValidator>
                        <br />
                        <span style="font-size:11px; color:#666;">请使用英文小写、数字、下划线，不能全部是数字或下划线。</span>
                    </td>
                </tr>
                <tr>
                    <td class="td_1">密码：</td>
                    <td class="td2">
                        <asp:TextBox ID="txtpassword" runat="server" Columns="40" TextMode="Password"></asp:TextBox>
                        &nbsp;
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtpassword" ErrorMessage="密码不为空" ForeColor="Red"></asp:RequiredFieldValidator>
                        <br />
                        <span style="font-size:11px; color:#666;">6-16位字符（字母、数字、符号），区分大小写</span>
                    </td>
                </tr>
                <tr>
                    <td class="td1">确认密码：</td>
                    <td class="td2"><asp:TextBox ID="txtpassword2" runat="server" Columns="40" TextMode="Password"></asp:TextBox>
                        &nbsp;
                        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="txtpassword" ControlToValidate="txtpassword2" ErrorMessage="密码不一致！" ForeColor="Red"></asp:CompareValidator>
                    </td>
                </tr>
                <tr>
                    <td class="td1">性别：</td>
                    <td class="td2">
                        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
                            <asp:ListItem>男</asp:ListItem>
                            <asp:ListItem>女</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="td1">昵称：</td>
                    <td class="td2">
                        <asp:TextBox ID="txtname1" runat="server" Columns="40"></asp:TextBox>
                        &nbsp;
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtname1" ErrorMessage="必填" ForeColor="Red"></asp:RequiredFieldValidator>
                    </td>
                </tr>
                <tr>
                    <td class="td1">用户角色：</td>
                    <td class="td2">
                        <asp:DropDownList ID="ddlRole" runat="server" CssClass="form-select">
                            <asp:ListItem Value="0">普通用户</asp:ListItem>
                            <asp:ListItem Value="1">卖家</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="td1">E-mail：</td>
                    <td class="td2">
                        <asp:TextBox ID="email" runat="server" Columns="40"></asp:TextBox>
                        &nbsp;
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="email" ErrorMessage="必填" ForeColor="Red"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="email" Display="Dynamic" ErrorMessage="您的E-mail输入有误！" ForeColor="Red" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td class="td1">手机号码：</td>
                    <td class="td2">
                        <asp:TextBox ID="txtPhoneNumber" runat="server" Columns="40"></asp:TextBox>
                        &nbsp;
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="电话号码无效！" ControlToValidate="txtPhoneNumber" ValidationExpression="^(\(\d{3}\)|\d{3}-)?\d{8}$|^[1][3-9]\d{9}$" ForeColor="Red"></asp:RegularExpressionValidator>
                    </td>
                </tr>
                <tr>
                    <td  class="td1">&nbsp;</td>
                    <td class="td2">
                        <div class="text-center">
                        <p>已有账号？<a href="Login.aspx">立即登录</a></p>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td  class="td1">&nbsp;</td>
                    <td class="later">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <asp:Button ID="Button1" runat="server" Text="注册" OnClick="Button1_Click" /></td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
